﻿package net.wangit.view.report;

import java.sql.Connection;

import net.wangit.jdbc.DB;


public class ReportSettings
{

	public static final ReportExporter PDF_REPORT_EXPORTER = new PdfReportExporter();
	public static final ReportExporter HTML_REPORT_EXPORTER = new HtmlReportExporter();
	private ReportExporter exporter;
	private DB db;
	private String sql;
	private Integer startPageIndex;
	private Integer endPageIndex;

	public ReportSettings()
	{
	}

	public Integer getEndPageIndex()
	{
		return endPageIndex;
	}

	public void setEndPageIndex(int endPageIndex)
	{
		this.endPageIndex = new Integer(endPageIndex);
	}

	public String getSql()
	{
		return sql;
	}

	public void setSql(String sql)
	{
		this.sql = sql;
	}

	public Integer getStartPageIndex()
	{
		return startPageIndex;
	}

	public void setStartPageIndex(int startPageIndex)
	{
		this.startPageIndex = new Integer(startPageIndex);
	}

	public DB getDB()
	{
		return db;
	}

	public Connection getConnection()
	{
		try{
			return db != null ? db.getConnection() : null;
		}catch(Exception e){
			return null;
		}
	}

	public void setDB(DB db)
	{
		this.db = db;
	}

	public ReportExporter getExporter()
	{
		return exporter != null ? exporter : PDF_REPORT_EXPORTER;
	}

	public void setExporter(ReportExporter exporter)
	{
		this.exporter = exporter;
	}

}
